-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[spin]: Rework trigger docs #1450
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Thorsten Hans <[email protected]>
|
||
You can leverage different triggers as part of your Spin apps to address common requirements and build real-world, distributed applications with Spin. | ||
|
||
### Common Triggers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what distinguishes a "common" trigger from a "community" one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought separation would make sense. Although mqtt
is mostly written by fermyon ppl, its not under the fermyon org.
If we don't care, we could roll with just a single (simple) list of all triggers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we just need to rephrase "common" to align more with "Fermyon"? It currently sounds like it contrasts with "rare" which is clearly not your intent!
|
||
You can leverage different triggers as part of your Spin apps to address common requirements and build real-world, distributed applications with Spin. | ||
|
||
### Common Triggers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wary of repeating this list on every trigger page. Could we maybe instead have a "See all Spin triggers" link to a top level page? Or nerd snip Karthik into giving us some kind of 'include from file' feature?
|
||
### Building and Running the Application | ||
|
||
We can immediately run this pre-written (template) application and observe the time-driven execution: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time-driven? Possible copypasta from cron?
<iframe width="560" height="315" src="https://www.youtube.com/embed/l2nh_xpjCiM?si=fBPaiqoIkJPQ95W_" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> | ||
|
||
If you would like to learn more about using the Spin Command Trigger, please check out the [Spin Command Trigger GitHub repository](https://github.com/fermyon/spin-trigger-command/). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to include a troubleshooting/gotchas section to cover how this doesn't play nice with multi-trigger applications?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the command trigger that is definitely super important and useful. Will add a corresponding paragraph
With the plugin and template installed, we create a new application: | ||
|
||
```bash | ||
spin new -t cron-rust hello_cron --accept-defaults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about --accept-defaults
here - people presumably care about the actual execution schedule, so showing they get a chance to enter it might be good.
|
||
### Building and Running the Application | ||
|
||
We can immediately run this pre-written (template) application and observe the time-driven execution: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am uncomfortable with "pre-written." "Template" or "starter" or "generated", but it's not really "pre-written".
cd hello_cron | ||
spin build --up | ||
|
||
Building component hello-cron with `cargo build --target wasm32-wasi --release` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should bump this to wasm32-wasip1 at some point (not a blocker here though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely, however all our templates are still using wasm32-wasi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/all/some\ of
@@ -111,6 +111,26 @@ | |||
{{/if}} href="{{site.info.base_url}}/spin/v3/redis-trigger">The Redis | |||
Trigger</a> | |||
</li> | |||
<li><a {{#if (active_project request.spin-full-url "/spin/v3/command-trigger" )}} class="active" | |||
{{/if}} href="{{site.info.base_url}}/spin/v3/command-trigger">The Command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you reckon is a good way to order the TOC here? The current scheme seems to be:
- built ins, in order of importance
- Fermyon-authored, in alphabetical? order
- non-Fermyon-authored, unordered
This kind of requires users to know the provenance of their trigger in order to find it, which feels awkward.
On the other hand, strict alphabetical would make HTTP disappear into the middle of the list, which doesn't feel like it well serves the most common user needs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can simple add "Available triggers" to the sidebar, and link to that page from each trigger instead of listing all there... feels smarter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I like that, it that would also give us a nice landing page for inbound links (and a place to explain the different statuses of the different triggers)
Co-authored-by: itowlson <[email protected]> Signed-off-by: Thorsten Hans <[email protected]>
Co-authored-by: itowlson <[email protected]> Signed-off-by: Thorsten Hans <[email protected]>
Co-authored-by: itowlson <[email protected]> Signed-off-by: Thorsten Hans <[email protected]>
|
||
> Please note: You can not `spin deploy` an application to Fermyon Cloud if it uses `kinesis` because non-HTTP triggers are not supported in Fermyon Cloud. | ||
|
||
Let's look at how the [experimental Kinesis trigger for Spin](https://github.com/ogghead/spin-trigger-kinesis) allows you to deploy an application that runs based on real time data records streamed through AWS Kinesis. (Provisioning and configuring AWS Kinesis is out of scope for this article). The Kinesis trigger leverages AWS credentials from the standard AWS configuration environment variables and maps a AWS Kinesis stream to a specific component. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could clarify this by saying something like "parses data records streamed through AWS Kinesis with customizable processing delay" -- but I wonder if it gets into the weeds a bit too much.
... DATA: { "value" : "bar" } | ||
``` | ||
|
||
As we can see from the above output, our application is now running and executing the function for each data record sent through your individual AWS Kinesis instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good callout @itowlson, agreed it might be worth rewording to clarify that function execution is per batch of records
|
||
> Please note: You can not `spin deploy` an application to Fermyon Cloud if it uses `kinesis` because non-HTTP triggers are not supported in Fermyon Cloud. | ||
|
||
Let's look at how the [experimental Kinesis trigger for Spin](https://github.com/ogghead/spin-trigger-kinesis) allows you to deploy an application that runs based on real time data records streamed through AWS Kinesis. (Provisioning and configuring AWS Kinesis is out of scope for this article). The Kinesis trigger leverages AWS credentials from the standard AWS configuration environment variables and maps a AWS Kinesis stream to a specific component. For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Knowing that an existing Kinesis stream and IAM credentials with permissions to read from it are prerequisites has benefit to readers if they are unfamiliar with AWS/are not ready to set those up. But it does also get into the weeds a bit.
Perhaps this information could live in a "prerequisites" subsection under "Installing the AWS Kinesis Trigger" before the sections on plugin installation/Spin configuration? Flexible on approach overall!
Unrelated, but it is potentially worth linking this AWS doc on credentials on "leverages AWS credentials from the standard AWS configuration environment variables" to help folks familiarize themselves with AWS credentials options.
```bash | ||
spin plugins install --url https://github.com/fermyon/spin-trigger-cron/releases/download/canary/trigger-cron.json | ||
``` | ||
### Common Triggers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, i see the categorization slightly differently, partially because i feel "common" is a little vague.
- Triggers built into the spin CLI (http and redis)
- Triggers maintained by Spin (command, cron, sqs, mqtt)
- Community triggers (kinesis)
I bubbled MQTT into spin because it is a part of spinkube but i see how that could be seen as a community trigger too.
This PR is a rework of trigger related Spin documentation.
Once all triggers are documented, users will
Sub Tasks
Merge once completed
Content must go through a pre-merge checklist.
Pre-Merge Content Checklist
This documentation has been checked to ensure that:
title
,template
, anddate
are all settemplates/*.hbs
files) that points to a document.md
that is set to publish in the future? If so please only publish the.md
and.hbs
changes in real-time (otherwise there will be a menu item pointing to a.md
file that does not exist)cat -ve <filename> | grep $'\r' | wc -l
and expect 0 as a result)bart check
PREVIEW_MODE=1
and runnpm run styles
to update styling)npm run test
and resolved all errors